<script setup lang="ts">
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'
import config from './config';
import { getToken } from './utils/auth';
import { useConfigStore } from '@/stores';

// 初始化应用
const initApp = () => {
  // 初始化应用配置
  initConfig()
  // 检查用户登录状态
  //#ifdef H5
  checkLogin()
  //#endif
}

const initConfig = () => {
  useConfigStore().setConfig(config)
}

// 跳转列表会刷新
const checkLogin = () => {
  if (!getToken()) {
    uni.reLaunch({ url: '/pages/login' })
  }
}
onLaunch(() => {
  initApp()
})
onShow(() => {
})
onHide(() => {
})
</script>

<style lang="scss">
// 全局变量
$primary-color: #409eff;
$success-color: #67c23a;
$warning-color: #e6a23c;
$danger-color: #f56c6c;
$info-color: #909399;

$text-primary: #2c3e50;
$text-regular: #606266;
$text-secondary: #909399;
$text-placeholder: #c0c4cc;

$border-color: #dcdfe6;
$border-light: #e4e7ed;
$border-lighter: #ebeef5;

$bg-color: #f5f7fa;
$bg-light: #f8f9fa;

$spacing-base: 8rpx;
$spacing-sm: 16rpx;
$spacing-md: 24rpx;
$spacing-lg: 32rpx;

// 全局样式
page {
  background-color: $bg-color;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
    Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

view,
navigator,
input,
scroll-view {
  box-sizing: border-box;
}

button::after {
  border: none;
}

swiper,
scroll-view {
  flex: 1;
  height: 100%;
  overflow: hidden;
}

image {
  width: 100%;
  height: 100%;
  vertical-align: middle;
}

// 通用样式类
.flex-center {
  display: flex;
  justify-content: center;
  align-items: center;
}

.ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}
</style>
